<?php 

	header('Content-type: image/jpeg');
	$type = $_POST['type'];
	$svg = (string) $_POST['svg'];
	$filename = (string) $_POST['filename'];
	$file=create_tmp($svg);
	$url=$file;
	$out='./out/'.uniqid().md5(time().uniqid()).'.jpg';
	$path = 'CutyCapt.exe';//你下载CutyCapt存放的位置
	$cmd = "$path --url=$url --out=$out";
	system($cmd);
	$ua = $_SERVER["HTTP_USER_AGENT"];
	if(preg_match('/MSIE/',$ua)) $filename=urlencode($filename);
	header("Content-Disposition: attachment; filename=".$filename.'.jpg');
	@readfile($out);
	unlink($out);
	unlink($url);
	
	function create_tmp($content){
		$filename='tmp/'.uniqid().md5(time().uniqid()).'.svg';
		$fp=fopen($filename,'w');
		file_put_contents($filename,$content);
		return $filename;
	}
?>